package com.michir.projects.jms.mocks;

import javax.jms.Message;
import javax.jms.MessageProducer;

import org.mockito.Mockito;

/**
 * {@link MessageProducer} Mocker: uses {@link Mockito}.
 * 
 * @author michir
 */
public class MessageProducerMocker {

	/**
	 * {@link MessageProducer} mock factory.
	 * @return a new mock instance
	 * @throws Exception
	 */
	public static MessageProducer mock(Message message) throws Exception {
		final MessageProducer producer = Mockito.mock(MessageProducer.class);
		Mockito.doNothing().when(producer).send(message);
		Mockito.doNothing().when(producer).close();
		return producer;
	}
}
